<?php 
session_start();
require_once('functions.php');
if($_SESSION['loggedIn'] != true) {redirect_php('login.php'); die;}
?>

<!DOCTYPE html>
<html>
	 <title>Чары</title>
<?php require_once('head.php');  ?>

<body>
	
	

<div class="main">
<?php require_once('menu.php');  ?>
<ol class="breadcrumb">
  <li><a href="/">Главная</a></li>
    <?php if  ($_GET['show_banned'] != 1) { ?>
        <li class="active"> Активные чары</li>
    <?php } else { ?>
        <li class="active">Забаненые чары</li>
    <?php } ?>



</ol>

<div class="panel panel-default ">
    <?php if  ($_GET['show_banned'] != 1) { ?>
    <div class="panel-heading"> <a href="/chars.php?show_banned=1" class="btn btn-info btn-sm">  Показать забаненых </a></div>
     <?php } else { ?>
    <div class="panel-heading"> <a href="/chars.php" class="btn btn-info btn-sm">  Показать разбаненых </a></div>
    <?php } ?>



  <!-- Table -->
  <table class="table table-bordered table-hover table-condensed" >
    <tr class="info">
        <style>
           table th a {
                color: grey; opacity: 0.3;
            }
        </style>
        <th>#</th>
        <th>Ник <a href="/chars.php?sort=charname"><span class="glyphicon glyphicon-chevron-up"></span></a>  <a href="/chars.php?sort=charname&order=1"><span class="glyphicon glyphicon-chevron-down"></a> </th>
        <th style="width: 70px;">vip <a href="/chars.php?sort=is_vip"><span class="glyphicon glyphicon-chevron-up"></span></a>  <a href="/chars.php?sort=is_vip&order=1"><span class="glyphicon glyphicon-chevron-down"></a> </th>
        <th>Сервер <a href="/chars.php?sort=server"><span class="glyphicon glyphicon-chevron-up"></span></a>  <a href="/chars.php?sort=server&order=1"><span class="glyphicon glyphicon-chevron-down"></a> </th>
        <th>Порт <a href="/chars.php?sort=port"><span class="glyphicon glyphicon-chevron-up"></span></a>  <a href="/chars.php?sort=port&order=1"><span class="glyphicon glyphicon-chevron-down"></a> </th>
        <th>lvl <a href="/chars.php?sort=level"><span class="glyphicon glyphicon-chevron-up"></span></a>  <a href="/chars.php?sort=level&order=1"><span class="glyphicon glyphicon-chevron-down"></a> </th>
        <th>PC <a href="/chars.php?sort=PC"><span class="glyphicon glyphicon-chevron-up"></span></a>  <a href="/chars.php?sort=PC&order=1"><span class="glyphicon glyphicon-chevron-down"></a> </th>
        <th style="width: 210px;">Последняя активность <a href="/chars.php?sort=lastactivity"><span class="glyphicon glyphicon-chevron-up"></span></a>  <a href="/chars.php?sort=lastactivity&order=1"><span class="glyphicon glyphicon-chevron-down"></a> </th>
        <th>Маржа</th>
        <th>Голды <a href="/chars.php?sort=gold"><span class="glyphicon glyphicon-chevron-up"></span></a>  <a href="/chars.php?sort=gold&order=1"><span class="glyphicon glyphicon-chevron-down"></a> </th>
        <th>Сумок <a href="/chars.php?sort=bags"><span class="glyphicon glyphicon-chevron-up"></span></a>  <a href="/chars.php?sort=bags&order=1"><span class="glyphicon glyphicon-chevron-down"></a> </th>
        <th>Действия</th>
    </tr>


<?php
	

 $q = "UPDATE `accounts` SET `state` = '0' WHERE  `lastactivity` < (NOW()- INTERVAL 10 MINUTE) AND `state` != -1";
  $f = mysql_query($q) or die("error 33");

//Запрос на бан
$state = "!= -1";
$state2 = $_GET['st']==-1?0:-1;
if ($_GET['show_banned'] == 1)
{
    $state = "= -1";
}

if (!empty($_GET['ban']))
{
    $query = "UPDATE `accounts` SET  `state`  = '".$state2."' WHERE  `accounts`.`id`  =".((int)$_GET['ban']);
    $fkhjgffkghkdfljyghlireugjeghlighdlijghkj = mysql_query($query) or die("error 33");
}


// добавление сортировки
$order_by = "ORDER BY `state`";
if (!empty($_GET['sort']))
{
    $order_by = "ORDER BY `".mysql_real_escape_string($_GET['sort'])."`";
}
if (!empty($_GET['order']))
{
    $order_by.=" DESC";
}




	$query = "SELECT * FROM accounts WHERE state ".$state."  ".$order_by."  ";
	$result = mysql_query($query) or die("error 33");
	for ($c=0; $c<mysql_num_rows($result); $c++)
	{
		$t = mysql_fetch_row($result);
		echo "<tr>";
			echo "<td>".($c+1)."</td>";  // $t[0] - id чара
			echo "<td><img height=\"16px\" src=\"i/status".$t[9].".png\"> <a href='/office.php?i=".$t[0]."'>".$t[2]."</a></td>"; // ник
			echo "<td data-toggle=\"modal\" data-target=\"#myModal".$t[0]."\" href=\"\" /*style=\"cursor: pointer;\" >"; if ($t[17]) {echo '<span class="label label-warning">vip</span>';} echo "</td>"; // vip
			echo "<td>".$t[3]."</td>"; // сервер
			echo "<td>".$t[8]."</td>"; // порт
			echo "<td>".$t[13]."</td>"; // левел
            echo "<td>".$t[4]."</td>"; // Комп
            echo "<td>".$t[5]."</td>"; // Последняя активность
            echo "<td style=\"color: "; if (suka($t[0]) > 0)  {echo "green";} else {echo "red";}    echo " \">".suka($t[0])." р.</td>"; // Рентабельность
            echo "<td>".$t[14]."</td>"; // голды
            echo "<td>".$t[15]."</td>"; // сумок
			echo "<td>".' <a href="/chars.php?ban='.$t[0].'&st='.$t[9].'" class="hov btn btn-info btn-xs" ">  ban </a> '."</td>";
		echo "</tr>";


// Модальное для просмотра Премиумов...
        echo '
<div class="modal fade" id="myModal'.$t[0].'" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content" style="padding: 10px;">';
      echo file_get_contents("http://u0014355.isp.regruhosting.ru/modal-vip.php");
      echo '  </div>
    </div>
</div>
';
// ...Модальное для просмотра Премиумов








	}
?>

  </table>
</div>

</div> <!--  main  -->







</body>
<html>



